package com.lanou.renrenxin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou.renrenxin.R;
import com.lanou.renrenxin.dao.Pricicy;

import java.util.List;

/**
 * Created by zy on 16/3/24.
 */
public class PrivicyAdapter extends BaseAdapter {
    private List<Pricicy> data;
    private Context context;

    public PrivicyAdapter(List<Pricicy> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data != null&&data.size()>0 ?data.size():0;
    }

    @Override
    public Object getItem(int position) {
        return data!=null&&data.size()>0 ?data.get(position):0;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_privicy, null);
            viewHolder = new ViewHolder();
            viewHolder.textView = (TextView) convertView.findViewById(R.id.item_privicy_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if (data != null) {
            viewHolder.textView.setText(data.get(position).getName());
//            viewHolder.userphotoIV.setImageResource(contactBean.getImageid());
        }
        return convertView;
    }
    class ViewHolder{
        TextView textView;
    }
}
